../.
weblib.sh
webhelp.sh
vx.sh
urldecode.sh
an urldecoder in pure bash; no external binaries used
i saw a couple of libs that actually did this by having a dictionary of common (eg %20 %22) encoded values and replacing them with their counterparts!!!!!


using it is pretty straightforward:

ENCODED_STRING="pies%20%22poep%22%20kak"
DECODED_STRING=$(urldecode "${ENCODED_STRING}")
echo "$DECODED_STRING"

pies "poep" kak


For example you can use it to parse the decoded values of a GET request into enviroment variables:

parse_getvars () {
for x in ${QUERY_STRING//&/" "}; do
export "HTTP_GET_$(urldecode "$x")"
done
}

it parses the query string into enviroment variables prefixed with HTTP_GET_

urldecode returns url decoded string from input

# urldecoding function for bash
# (c) 2003 GPL by Matthijs Dalhuijsen
# check http://www.gnu.org/gpl for details

urldecode () {
local bf=
local cb=
local hi=0
local le=0
local x=-1
for p in "$@"; do
le="${#p}"
while (( x++ < le )); do
case "${p:${x}:1}" in
"%")
if (( hi == 0 )); then
(( hi++ ))
else
bf="${bf}${p:${x}:1}"
hi=0
fi
;;
"+")
bf="${bf} "
;;
*)
if (( hi == 0 )); then
bf="${bf}${p:${x}:1}"
fi
if (( hi == 2 )); then
cb="${cb}${p:${x}:1}"
bf="${bf}$(echo -e "\\x${cb}")"
hi=0
fi
if (( hi == 1 )); then
cb=${p:${x}:1}
(( hi++ ))
fi
;;
esac
done
done
echo -n "$bf";
}

*mental note (update)!*
more perlish would be (and i think a 4 liner....) to split on % and then match the first 2 chars of the chunks, ..
a bit like in parse_getvars() above

rand.sh
obsoleter.sh
funcookie.sh
apple.sh